package com.sgcc.fj.pmos.e_fj_home.presenter;


import com.sgcc.fj.pmos.common.base.BasePresenter;
import com.sgcc.fj.pmos.common.http.HttpInterConst;
import com.sgcc.fj.pmos.common.http.HttpRequestUtils;
import com.sgcc.fj.pmos.common.http.MvpNetCallback;
import com.sgcc.fj.pmos.e_fj_home.bean.UserTypeListBean;
import com.sgcc.fj.pmos.e_fj_home.contract.UserTypeListContract;

import java.util.HashMap;
import java.util.Map;

import okhttp3.Call;


public class UserListPresenter extends BasePresenter<UserTypeListContract.View> implements UserTypeListContract.Presenter {


    @Override
    public void getUserTypeList(String mktYear) {
        Map<String, Object> params = new HashMap<>();
        params.put("mktYear", mktYear);
//        data.put("mktYear", 2022);

        HttpRequestUtils.getInstance().request(params, HttpInterConst.HOME_QUERYUSERTYPELIST, new MvpNetCallback<UserTypeListBean>(getView(), true) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
                getView().queryFaile();
            }

            @Override
            public void onResponse(UserTypeListBean response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                getView().querySuccess(response);
            }
        });
    }




}
